﻿using Prism.Mvvm;
using SmartPlant.Model.Biz;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartPlant.Modules.Base.UIEntity
{
    public class TabItemModel : BindableBase
    {
        public string Header { get; set; }
        private bool isSelected = false;

        public bool IsSelected
        {
            get { return isSelected; }
            set
            {
                isSelected = value;
                RaisePropertyChanged();
            }
        }

        public ObservableCollection<ContentItemModel> ContentItems { get; set; }

        public TabItemModel(string header)
        {
            Header = header;
            ContentItems = new ObservableCollection<ContentItemModel>();
        }
    }

    public class ContentItemModel : BindableBase
    {
        /// <summary>
        /// <see cref="ViewQueryItemAttr.DisplayName"/>
        /// </summary>
        public string DisplayName { get; set; }
        /// <summary>
        /// 可能是属性值
        /// </summary>
        private string _value;
        public string Value
        {
            get { return _value; }
            set
            {
                _value = value;
                RaisePropertyChanged();
            }
        }


        /// <summary>
        /// 下拉列表里选中的内容（相当于单位 UDT等）
        /// </summary>
        private DropDownListObj selectedItem;
        /// <summary>
        /// 下拉列表里选中的内容（相当于单位 UDT等）
        /// </summary>
        public DropDownListObj SelectedItem
        {
            get { return selectedItem; }
            set
            {
                selectedItem = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 可能是下拉列表
        /// </summary>
        public ObservableCollection<DropDownListObj> Items { get; set; }
        public ContentItemType Type { get; set; }
        public bool IsReadOnly { get; set; }
        /// <summary>
        /// <see cref="ViewQueryItemAttr.WPF_UniqueName"/>
        /// </summary>
        public string PropertyName { get; set; }

        /// <summary>
        /// 对应的UoM的属性
        /// </summary>
        public string PropertyUoMName { get; set; }
        /// <summary>
        /// <see cref="ViewQueryItemAttr.SPIColName"/>
        /// </summary>
        public string SPIColName { get; set; }
        public bool IsVisible { get; set; }
        public ContentItemModel(string propName, string SPIColName, string displayName, ContentItemType contextItemType, bool isReadOnly = false)
        {
            IsVisible = true;
            PropertyName = propName;
            this.SPIColName = SPIColName;
            DisplayName = displayName;
            Type = contextItemType;
            IsReadOnly = isReadOnly;
            Items = new ObservableCollection<DropDownListObj>();
        }
    }

    public enum ContentItemType
    {
        Text,
        Combox,
        TextCombox
    }
}
